@extends('layout/default')

@section('content')

    <div class="container ">
        <div clas="row ">
            <form METHOD="post" >
                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                <input type="hidden" name="CWebChatID" value="{{Session::get('CWebChatID')}}">
                <input type="hidden" name="nickname" value="{{Session::get('CName')}}">

                <div class=" col-xs-12 box-content">
                    <div class="row ">
                        <div class="col-xs-12"><label >微信用户：{{Session::get('CName')}}</label></div>

                    </div>
                    <div class="row ">
                        <label class=" form-label" for="mobile">手机：</label>
                        <div class="col-xs-12"><input class="form-input " id="mobile" name="CMobile" value="{{Input::get('CMobile')}}" required pattern="^1[3|4|5|8][0-9]\d{4,8}$" placeholder="11位手机号" maxlength="11"></div>

                    </div>
                    <div class="row ">
                        <label class=" form-label" for="mobile">密码：</label>
                        <div class="col-xs-12"><input class=" form-input" id="pwd" name="CPwd" type="password" value="{{Input::get('CPwd')}}"required parent="^[A-Za-z0-9]{7}$" placeholder="6-20位数字或字符"></div>
                    </div>
                </div>
                <input class="col-xs-12 box-footer btn btn-primary" value="绑定" type="submit" >
                没有账号?立即<a href="{{url('register')}}">注册</a>


            </form>
        </div>

    </div>
@endsection
@section('scripts')
    <script>
        $(function()
        {
            $('#get-code').click(function(){

                $.ajax({
                    url:"{{url('/code')}}",
                    type:'GET',
                    data:{
                        _token:"{{csrf_token()}}",
                        ctype:1,
                        CMobile:$('input[name="CMobile"]').val()
                    },
                    success:function(data){

                        $('#get-code').attr('disabled',true)
                        var i=60;
                        var interval= setInterval(function(){
                            i--;
                            if(i==0)
                            {
                                $('#get-code').attr('disabled',false).val('获取验证码');

                                clearInterval(interval)
                            }else{

                                $('#get-code').val(i+'秒后重新获取');
                            }

                        },1000)
                        //测试
                        if(data){
                            $('input[name="cnum"]').val(data)
                        }
                    }
                })

            })
            //字段验证


        })

    </script>
@endsection